package com.gremlin.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * Description: 发件人信息配置
 * @Author: gremlin
 * Date: 2022/3/4 10:00
 * @Version: 1.0
 */
@Component
public class SenderInfoUtils implements InitializingBean {

    @Value("${email_info.emailAccount}")
    private String sendEmailAccount;

    /**
     * 发件人邮箱密码: 有些邮箱服务器为了增加邮箱本身密码的安全性，
     * 给SMTP 客户端设置了独立密码（有的邮箱称为“授权码”）,
     * 对于开启了独立密码的邮箱, 这里的邮箱密码必需使用这个独立密码（授权码）。
     */
    @Value("${email_info.emailPassword}")
    private String sendEmailPassword;

    @Value("${email_info.authCode}")
    private String authCode;

    @Value("${email_info.emailHost}")
    private String sendEmailHost;

    public static String EMAIL_ACCOUNT;
    public static String EMAIL_PASSWORD;
    public static String EMAIL_HOST;
    public static String EMAIL_AUTH_CODE;

    @Override
    public void afterPropertiesSet() {
        EMAIL_ACCOUNT = sendEmailAccount;
        EMAIL_PASSWORD = sendEmailPassword;
        EMAIL_HOST = sendEmailHost;
        EMAIL_AUTH_CODE = authCode;
    }
}
